package end.handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import end.bean.shiro.Manager;
import end.constant.Const;

public class LoginHandlerInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		HttpSession session = request.getSession();
		Manager manager = (Manager) session.getAttribute(Const.SESSION_USER);
		if (manager != null) {
			return true;
		} else {
			response.sendRedirect(request.getContextPath() + "/login.html");
			return false;
		}
	}
}
